*===============================================================================
*
*					WORKER BELIEFS ABOUT OUTSIDE OPTIONS
*		(c)	Simon Jaeger, Christopher Roth, Nina Roussille, Benjamin Schoefer
*							  2023 December 5
*						   	   SOEP-IAB Data 
*
*===============================================================================


********************************************************************************
*								Figure B05 ab								   *
********************************************************************************

cap log close      
log using ${log}/FigureB05ab.log, replace       


* Figure A5 ab

cap log close                                             
log using ${log}/FigureB05ab.log, replace
	
foreach sample in "FTp_" "FTp_u_" {
	use "$data/`sample'_finaldata.dta", clear
	
	* winsorizing
	cap drop actual_ln_mover_change_r0 
	winsor mean_delta_ln_wage_mover_r0_2015, gen(actual_ln_mover_change_r0) p(0.02) 
	cap drop actual_ln_mover_change_r1 
	winsor mean_delta_ln_wage_mover_r1_2015, gen(actual_ln_mover_change_r1) p(0.02)
	
	* calculating coefficient
	reg actual_ln_mover_change_r1 actual_ln_mover_change_r0 if ln_own_change_w!=., cluster(pid)
		local N_obs_fs = e(N)
		local beta_fs = string(round(_b[actual_ln_mover_change_r0],0.001),"%4.3f")
		local se_fs = string(round(_se[actual_ln_mover_change_r0],0.001),"%4.3f")
					
	* calculating axis ranges		
	local min = 0
	local max = 0
	foreach minmaxvar in actual_ln_mover_change_r1 actual_ln_mover_change_r0 {
		quietly su `minmaxvar', d
		if r(p5)<`min' local min = r(p5)
		if r(p95)>`max' local max = r(p95)
	}
						
	binscatter actual_ln_mover_change_r1 actual_ln_mover_change_r0, ///
		msymbols(circle none) xtitle("Actual Wage Change of Movers (50% Random Sample B)") ytitle("Actual Wage Change of Movers" "(50% Random Sample A)") ///
		legend(on order(- "Slope: `beta_fs' (SE `se_fs')") region(lwidth(none)) pos(11) ring(0)) ///
		lcolors(maroon black)  ///
		xscale(range(`min' `max')) yscale(range(`min' `max')) ylabel(#10,grid) xlabel(#10,grid)
	if "`sample'"=="FTp_u_"{ // EUE movers, Figure B05 a 
		graph export ${log}/FigureB05a.pdf, replace			
	}		
	if "`sample'"=="FTp_"{ // all movers, Figure B05 b 
		graph export ${log}/FigureB05b.pdf, replace			
	}
}

	
cap log close
clear
